/**  
* @Title: TbTimer.java
* @Package com.lemon.timer
* @Description: (一句话阐述):
* @author Ran_cc
* @date 2018年5月22日
* @version V1.0  
*/
package com.lemon.timer;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;

import com.lemon.conf.MyException;
import com.lemon.conf.redis.RedisUtil;

import redis.clients.jedis.Jedis;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Company: </p>
 * @author Ran_cc
 * @date 2018年5月22日
 * @版本 V 1.0 
 */
/*@Component
@EnableScheduling*/
public class TbTimer {
	
	private static final Logger log = LoggerFactory.getLogger(TbTimer.class);
	
	@Resource
	//	private CommodityVipCouponService vipService;
	
	
	private String[] channel = {"","couponlist_jiajujiazhuang","couponlist_shumajiadian","couponlist_muying","couponlist_shipin","couponlist_nvzhuang","couponlist_xiebaopeishi","couponlist_meizhuanggehu","couponlist_nanzhuang","couponlist_neiyi","couponlist_yundonghuwai"};
	private int page = 0;
	private int ind = 1 ; 
	boolean flag = false;
	@Scheduled(cron="0/15 * * * * ?") 
	public void executeFileDownLoadTask() {
		/*// 间隔3秒,执行任务 
		Thread current = Thread.currentThread(); 
		System.out.println("定时任务1:"+current.getId());
		System.out.println(StringUtil.DateToString(new Date(), 41));
		
		page++;
		
		
		log.error("定时任务1:"+current.getId()+":"+page);
		*/
		if(page>500){
			log.error("已超过500页,换下一个列表数据:"+ind);
			page=0;
			ind++;
			return;
		}
		Jedis jd = RedisUtil.getJedis();;
		try {
			
			if(!flag){
				page =Integer.parseInt(jd.get("timer_page"));
				ind =Integer.parseInt(jd.get("timer_page_1"));
				flag = true;
			}
			jd.set("timer_page",page+"");
			jd.set("timer_page_1",ind+"");
			System.out.println(jd.get("timer_page"));
		} catch (Exception e) {
			//将错误信息输出到日志
			MyException.writeErr(e, "error info");
		}finally {
			jd.close();
		}
		
		
		
	}
	
	/*@Scheduled(cron="0/2 * * * * ?") 
	public void executeFileDownLoadTask2() {
		// 间隔2分钟,执行任务 
		Thread current = Thread.currentThread(); 
		try {
			Thread.sleep(10000);
		} catch (InterruptedException e) {
			//将错误信息输出到日志文件
			MyException.writeErr(e);
		}
		System.out.println("定时任务2:"+current.getId());
	}
	@Scheduled(cron="0/5 * * * * ?") 
	public void executeFileDownLoadTask3() {
		// 间隔2分钟,执行任务 
		Thread current = Thread.currentThread(); 
		System.out.println("定时任务3:"+current.getId());
	}*/
	
	public static void main(String[] args) {
		String s = "2.1";
		int ss = 1 ; 
		
		System.out.println( String.format("%.2f", Double.parseDouble(s)-Double.parseDouble(ss+"")));
	}
	
}
